package com.ruoyi.web.Service.Impl;

import com.ruoyi.web.Service.PermitService;
import com.ruoyi.web.domain.PermitInfo;
import com.ruoyi.web.mapper.PermitMapper;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @program: my-ruoyi-master_202130504106_李航
 * @description:
 * @author: LiHang
 * @create: 2021-10-18 18:27
 **/

@Service
public class PermitServiceImpl implements PermitService {


    @Autowired
    PermitMapper permitMapper;

    /**
     * 根据用户主键查询其所能看的看到的菜单的ID
     * @param roleId
     * @return
     */
    @Override
    public List<Long> selectPermitMenuId(Long roleId) {
        return permitMapper.selectPermitMenuId(roleId);
    }

    /**
     * 根据用户主键查询权限（能看的功能）
     * @param roleId
     * @return
     */
    @Override
    public List<PermitInfo> selectPermit(Long roleId) {
        List<PermitInfo> permitInfos = permitMapper.selectPermit(roleId);
        return permitInfos;
    }

    /**
     * 添加权限
     * @param permitInfo
     * @return
     */
    @Override
    public int insertPermit(PermitInfo permitInfo) {
        int count = permitMapper.insertPermit(permitInfo);
        return count;
    }

    /**
     * 删除某用户的某个功能权限
     * @param permitInfo
     * @return
     */
    @Override
    public int deletePermit(PermitInfo permitInfo) {
        int count  = permitMapper.deletePermit(permitInfo);
        return count;
    }
}
